function serDlg() {
    $("#searchDlg").modal();
    document.getElementById("search_input").value="";
}


var $search=$("#search_button");
function validateSearchId() {
    return $("#select").validate({
        rules: {
            search_input: {
                digits: true
            }
        },
        messages: {
            search_input: {
                digits: "id必须是整数！"
            }
        }
    });
}
$search.click(function () {
    var value = $("#search_select ").val();//获取select的值
    if(value==="princId") {
        if(validateSearchId().form()) {
            searchprincId();
        }
    } else if(value==="variaAccou"){
        searchvariaAccou();
    } else if(value==="calcuStyle"){
        searchcalcuStyle();
    } else if(value==="princName"){
        searchprincName();
    } else if(value=="nameEngli"){
        searchnameEngli();
    }
    else if(value=="variaNo1"){
        searchvariaNo1();
    }
    else if(value=="variaNo2"){
        searchvariaNo2();
    }
    else if(value=="variaNo3"){
        searchvariaNo3();
    }
    else if(value=="variaNo4"){
        searchvariaNo4();
    }
});

function searchprincId() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据

            url: "/principle/find/princId",
            datatype: 'json',
            mtype: "post",
            postData: {"princId": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }

}

function searchvariaAccou() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/variaAccou",
            datatype: 'json',
            mtype: "post",
            postData: {"variaAccou": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchcalcuStyle() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/calcuStyle",
            datatype: 'json',
            mtype: "post",
            postData: {"calcuStyle": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchprincName() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/princName",
            datatype: 'json',
            mtype: "post",
            postData: {"princName": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchnameEngli() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/nameEngli",
            datatype: 'json',
            mtype: "post",
            postData: {"nameEngli": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchvariaNo1() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/variaNo1",
            datatype: 'json',
            mtype: "post",
            postData: {"variaNo1": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchvariaNo2() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/variaNo2",
            datatype: 'json',
            mtype: "post",
            postData: {"variaNo2": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}
function searchvariaNo3() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/variaNo3",
            datatype: 'json',
            mtype: "post",
            postData: {"variaNo3": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}

function searchvariaNo4() {
    var id = $("#search_input").val().replace(/(^\s*)|(\s*$)/g, "");//replace用于去掉首尾的空格
    if(id!==null&&id!==undefined&&id!=="") {
        $('#searchDlg').modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
        $table.jqGrid('clearGridData');
        $table.jqGrid('setGridParam', {  // 重新加载数据
            url: "/principle/find/variaNo4",
            datatype: 'json',
            mtype: "post",
            postData: {"variaNo4": id}
        }).trigger("reloadGrid");
    }
    else {
        $("#searchDlg").modal('hide').on("hidden", function () {
            $(this).removeData("modal");
        });
    }
}